<?php

/**
 * Flickr Photosets - Profile Page
 * Renders the user's profile box.
 * 
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @version 2.0.2
 * @date 10/13/07
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 * @since File available since Release 1.0
 */

/*
Require the function library
This will include all other necessary files
*/
require_once 'lib.php';

/*
Initialize Flickr Photosets
*/
$fp = new FlickrPhotosetsProfile();

?>

<?php if ($fp->preview_mode) { ?>
	
	
	<div style="width: 416px;">
		<div class="preview_border" style="width: 416px;">
			<div class="html_preview" style="width: 416px;">
				<div class="profile_box flex_shut">
					<div class="box_head clearfix">
						<h2>Profile Box Preview (may not appear exactly as shown)</h2>
					</div>
					<div class="box_subhead clearfix">
						<div class="box_subtitle">
							<?=$fp->profile['subtitle']?>
						</div>
						<div class="box_actions">
							<a href="<?=$fp->profile['see_all_url']?>">See All</a>
						</div>
					</div>
					<div class="inside_the_box clearfix">
						
						
						<?php // Sets
						if ($fp->config['profile_display'] == $fp->profile_display['sets'] or $fp->config['profile_display'] == $fp->profile_display['random_sets']) { ?>

							<div>
								<div id="photos_box" class="clearfix">
									<?php foreach ($fp->photos['photo'] as $photo) { 
										$path = $fp->app_url.'/photos/'.$fp->uid.'/sets/'.$photo['set']['id'].'/';
									?>
										<div style="float:left;">
											<div style="width: 82px; float: left;">
												<a href="<?=$path?>"><img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" class="image" alt="<?=$photo['set']['title']?>" title="<?=$photo['set']['title']?>" /></a>
											</div>

											<div style="width: 110px; float: left;">
												<div>
													<strong><a href="<?=$path?>"><?=$photo['set']['title']?></a></strong>
												</div><span class="date"><?=$photo['set']['photos']?> Photos</span>
											</div>
										</div>
									<?php } ?>
									<div style="clear:both;"></div>
								</div>
							</div>

						<?php } // Overview
						else if ($fp->config['profile_display'] == $fp->profile_display['overview']) { ?>

							<div>
								<div id="photos_box" class="clearfix">
										<div style="float:left;">
											<div style="width: 55px; float: left;">
												<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><img src="http://flickr.com/buddyicons/<?=$fp->nsid?>.jpg" class="image" alt="<?=$fp->flickr_user['username']?>" title="<?=$fp->flickr_user['username']?>" /></a>
											</div>

											<div style="width: 300px; float: left;">
												<h3><?=$fp->flickr_user['username']?>
												<?php if ($fp->flickr_user['ispro']) { ?>
													<a href="http://www.flickr.com/account/"><img src="http://l.yimg.com/www.flickr.com/images/badge_pro.gif.v2" width="20" height="12" alt="Pro User" align="absmiddle" class="Pro" /></a>
												<?php } ?></h3>
												<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><?=$fp->flickr_user['photos']['count']?> photos</a><br/>
												Member since: <?=date("F j, Y", $fp->flickr_user['photos']['firstdate'])?>
											</div>
										</div>
									<div style="clear:both;"></div>
								</div>
							</div>

						<?php } // Photos
						else { ?>

							<center>
							<ul style="margin:auto;padding:0;width:100%;">
								<?php foreach ($fp->photos['photo'] as $photo) { ?>
									<li style="display:inline;padding:0;">
										<a href="<?=$fp->app_url.'/photos/'.$fp->uid.'/'.$photo['id'].'/'?>">
											<img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" style="margin-right:1px;margin-bottom:-1px;" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" />
										</a>
									</li>
								<?php } ?>
							</ul>
							</center>

						<?php } ?>
						
						
						<p style="margin-bottom:0; color: #aaa; font-size: 9px; line-height: 11px;">
							Last updated <?=date("F j, Y \a\\t g:i A (T)")?><br />Refresh photos or configure profile settings
						</p>
						
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<p><em>This is to give you an idea of what the profile box will look like. When it is actually generated, the photos may (and probably will) be different.</em></p>
	
	
<?php } else { ?>
	
	
	<fb:fbml version="1.1">	

		<fb:profile-action url="<?=$fp->app_url?>/photos/<?=$fp->uid?>/">View <fb:name uid="profileowner" possessive="true" firstnameonly="true" /> Flickr Photos</fb:profile-action>

		<fb:subtitle seeallurl="<?=$fp->profile['see_all_url']?>">
			<?=$fp->profile['subtitle']?>
		</fb:subtitle>
		
		<?php // Sets
		if ($fp->config['profile_display'] == $fp->profile_display['sets'] or $fp->config['profile_display'] == $fp->profile_display['random_sets']) { ?>
			
			<fb:narrow>

				<?php // Narrow column view ?>
				<div>
					<div id="photos_box" class="clearfix">
						<?php foreach ($fp->photos['photo'] as $photo) { 
							$path = $fp->app_url.'/photos/'.$fp->uid.'/sets/'.$photo['set']['id'].'/';
						?>
							<div class="album" style="float:left;">
								<div style="width: 82px; float: left;">
									<a href="<?=$path?>"><img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" class="image" alt="<?=$photo['set']['title']?>" title="<?=$photo['set']['title']?>" /></a>
								</div>

								<div style="width: 75px; float: left;">
									<div>
										<strong><a href="<?=$path?>"><?=$photo['set']['title']?></a></strong>
									</div><span class="date"><?=$photo['set']['photos']?> Photos</span>
								</div>
							</div>
						<?php } ?>
						<div style="clear:both;"></div>
					</div>
				</div>

			</fb:narrow>
			<fb:wide>

				<?php // Wide column view ?>
				<div>
					<div id="photos_box" class="clearfix">
						<?php foreach ($fp->photos['photo'] as $photo) { 
							$path = $fp->app_url.'/photos/'.$fp->uid.'/sets/'.$photo['set']['id'].'/';
						?>
							<div class="album" style="float:left;">
								<div style="width: 82px; float: left;">
									<a href="<?=$path?>"><img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" class="image" alt="<?=$photo['set']['title']?>" title="<?=$photo['set']['title']?>" /></a>
								</div>

								<div style="width: 95px; float: left;">
									<div>
										<strong><a href="<?=$path?>"><?=$photo['set']['title']?></a></strong>
									</div><span class="date"><?=$photo['set']['photos']?> Photos</span>
								</div>
							</div>
						<?php } ?>
						<div style="clear:both;"></div>
					</div>
				</div>

			</fb:wide>
			
		<?php } // Overview
		else if ($fp->config['profile_display'] == $fp->profile_display['overview']) { ?>
			
			<fb:narrow>

				<?php // Narrow column view ?>
				<div>
					<div id="photos_box" class="clearfix">
							<div style="float:left;">
								<div style="width: 55px; float: left;">
									<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><img src="http://flickr.com/buddyicons/<?=$fp->nsid?>.jpg" class="image" alt="<?=$fp->flickr_user['username']?>" title="<?=$fp->flickr_user['username']?>" /></a>
								</div>

								<div style="width: 125px; float: left;">
									<h3><?=$fp->flickr_user['username']?>
									<?php if ($fp->flickr_user['ispro']) { ?>
										<a href="http://www.flickr.com/account/"><img src="http://l.yimg.com/www.flickr.com/images/badge_pro.gif.v2" width="20" height="12" alt="Pro User" align="absmiddle" class="Pro" /></a>
									<?php } ?></h3>
									<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><?=$fp->flickr_user['photos']['count']?> photos</a><br/>
									Member since: <?=date("F j, Y", $fp->flickr_user['photos']['firstdate'])?>
								</div>
							</div>
						<div style="clear:both;"></div>
					</div>
				</div>

			</fb:narrow>
			<fb:wide>

				<?php // Wide column view ?>
				<div>
					<div id="photos_box" class="clearfix">
							<div style="float:left;">
								<div style="width: 55px; float: left;">
									<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><img src="http://flickr.com/buddyicons/<?=$fp->nsid?>.jpg" class="image" alt="<?=$fp->flickr_user['username']?>" title="<?=$fp->flickr_user['username']?>" /></a>
								</div>

								<div style="width: 300px; float: left;">
									<h3><?=$fp->flickr_user['username']?>
									<?php if ($fp->flickr_user['ispro']) { ?>
										<a href="http://www.flickr.com/account/"><img src="http://l.yimg.com/www.flickr.com/images/badge_pro.gif.v2" width="20" height="12" alt="Pro User" align="absmiddle" class="Pro" /></a>
									<?php } ?></h3>
									<a href="<?=$fp->app_url?>/photos/<?=$fp->uid?>/"><?=$fp->flickr_user['photos']['count']?> photos</a><br/>
									Member since: <?=date("F j, Y", $fp->flickr_user['photos']['firstdate'])?>
								</div>
							</div>
						<div style="clear:both;"></div>
					</div>
				</div>

			</fb:wide>
			
		<?php } // Photos
		else { ?>
			
			<fb:narrow>

				<?php // Narrow column view ?>
				<center>
					<ul style="margin:auto;padding:0;width:100%;"><?php foreach ($fp->photos['photo'] as $photo) { ?><li style="display:inline;padding:0;margin:0;"><a href="<?=$fp->app_url.'/photos/'.$fp->uid.'/'.$photo['id'].'/'?>"><img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" style="margin:1px 1px -2px 0;padding:0;" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" /></a></li><?php } ?></ul>
				</center>

			</fb:narrow>
			<fb:wide>

				<?php // Wide column view ?>
				<ul style="margin:auto;padding:0;width:100%;"><?php foreach ($fp->photos['photo'] as $photo) { ?><li style="display:inline;padding:0;margin:0;"><a href="<?=$fp->app_url.'/photos/'.$fp->uid.'/'.$photo['id'].'/'?>"><img src="<?=$fp->flickr->buildPhotoUrl($photo, $fp->photo_size)?>" style="margin:1px 1px -2px 0;padding:0;" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" /></a></li><?php } ?></ul>

			</fb:wide>
			
		<?php } ?>
		
		<p style="margin-bottom: 0; color: #aaa; font-size: 9px; line-height: 11px;">
			Last updated <?=date("F j, Y \a\\t g:i A (T)")?>
			<fb:visible-to-owner>
				<br/><a href="<?=$fp->app_url?>/update.php?fromprofile">Refresh photos</a> or <a href="<?=$fp->app_url?>/configure.php#profile">configure profile settings</a>
			</fb:visible-to-owner>
		</p>

	</fb:fbml>
	
	
<?php } ?>